home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 22 code / PCI Driver Sample / NCR_DriverProject / Src / DriverGestaltHandler.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-19  |  3.0 KB  |  91 lines  |  [TEXT/MPCC]

  1. /*                                    DriverGestaltHandler.c                            */
  2. /*
  3.  * DriverGestaltHandler.c
  4.  * Copyright © 1994 Apple Computer Inc. All rights reserved.
  5.  *
  6.  */
  7. /*    .___________________________________________________________________________________.
  8.       | This subroutine is called by the Driver Status function to handle Driver Gestalt    |
  9.     | (PBStatus csCode 43) requests. You could use this as a template, extending and    |
  10.     | modifying it for your particular needs.                                            |
  11.     .___________________________________________________________________________________.
  12. */
  13.  
  14. #include "NCRDriverPrivate.h"
  15.  
  16. /*
  17.  * Called on PBStatus, csCode = 43
  18.  */
  19. OSErr
  20. DriverGestaltHandler(
  21.         register CntrlParam        *pb
  22.     )
  23. {
  24.         OSErr                    status;
  25.         UInt32                    defaultPowerConsumption;
  26. #define PB        (*((DriverGestaltParam *) pb))
  27. #define OPTIONS    (TheDriverDescription.driverOSRuntimeInfo)
  28.  
  29.         Trace(DriverGestaltHandler);
  30.         PB.driverGestaltResponse = 0;
  31.         status = noErr;
  32.         switch (PB.driverGestaltSelector) {
  33.         case driverGestaltSync:
  34.             PB.driverGestaltResponse = FALSE;    /* We handle asynchronous I/O        */
  35.             break;
  36.         case driverGestaltVersion:
  37.             PB.driverGestaltResponse = 
  38.                 *((long *) &TheDriverDescription.driverType.version);
  39.             break;
  40.         case driverGestaltDeviceType:
  41.             /*
  42.              * I don't know the proper type for this device -- although we perform
  43.              * SCSI operations, that might confuse callers who would presume that
  44.              * this driver is used by SCSI Manager 4.3, which is incorrect.
  45.              * In the meantime, I'll use the creator type (which is all uppercase).
  46.              */
  47.             PB.driverGestaltResponse = kCreatorType;
  48.             break;
  49.         case driverGestaltInterface:
  50.             PB.driverGestaltResponse = 'pci ';
  51.             break;
  52.         case kDriverGestaltPowerSwitch:        /* Support Power up/down switching?        */
  53.             PB.driverGestaltResponse = FALSE;    /* Not supported yet                 */
  54.             break;
  55.         case kDriverGestaltPowerMode:        /* TRUE if in high-power mode            */
  56.             PB.driverGestaltResponse = TRUE;    /* Power-switching is not supported */
  57.             break;
  58.         case kDriverGestalt5MaxHighPower:    /* Max 5 volt uAmps in high-power mode    */
  59.             /*
  60.              * Response in microwatts - Idd (mAmp) * Vdd (Volts) * 1000 from handbook
  61.              */
  62.             defaultPowerConsumption = (130L * 1000L * 5L);
  63.             goto driverPowerCommon;
  64.         case kDriverGestalt5MaxLowPower:    /* Max 5 volt uAmps in low-power mode    */
  65.             /*
  66.              * Response in microwatts - Idd (mAmp) * Vdd (Volts) * 1000 from handbook
  67.              */
  68.             defaultPowerConsumption = (1L * 1000L * 5L);
  69.             goto driverPowerCommon;
  70.         case kDriverGestalt3MaxHighPower:    /* Max 3 volt uAmps in high-power mode    */
  71.             defaultPowerConsumption = 0;
  72.             goto driverPowerCommon;
  73.         case kDriverGestalt3MaxLowPower:    /* Max 3 volt uAmps in low-power mode    */
  74.             defaultPowerConsumption = 0;
  75.             goto driverPowerCommon;
  76. driverPowerCommon:
  77.             PB.driverGestaltResponse = GetDevicePowerConsumption(
  78.                         &GLOBAL.deviceEntry,
  79.                         PB.driverGestaltSelector,
  80.                         defaultPowerConsumption
  81.                     );
  82.             break;
  83.         default:
  84.             LogHex(PB.driverGestaltSelector, "\pUnknown driver gestalt");
  85.             status = statusErr;            
  86.             break;
  87.         }
  88.         return (status);
  89. #undef PB
  90. }
  91.